// Astar.h: interface for the Astar class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ASTAR_H__AE0177F8_57A3_4848_A8CD_1156DC834E65__INCLUDED_)
#define AFX_ASTAR_H__AE0177F8_57A3_4848_A8CD_1156DC834E65__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef __int64 I64;

#include "Node.h"
#include <queue> 
#include <map>   
#include "defsSolver.h"

using namespace std;

#define MAXNODES 110000000


class Astar  
{
	map<I64, int> myOpenList;  //<I64 , int) //bits 0-7 gValue; bits 8-16 h Value
	map<I64, int> myCloseList; //<I64 , int) //bits 0-7 gValue; bits 8-16 h Value

	priority_queue<NodeState> myPQueue;

	void ResetMemory();

public:
	Astar();
	virtual ~Astar();
	void Reset();
	bool IsPQueueEmpty();
	void PrintAndReleasePQueue();

	void AddStateToOpenList(I64 hashVal, int gVal, int hVal);
	bool GetStateFromOpenList(I64 hashVal, unsigned char &gVal, unsigned char &hVal);

	void AddStateToCloseList(I64 hashVal, int gVal, int hVal);
	bool GetStateFromCloseList(I64 hashVal, unsigned char &gVal, unsigned char &hVal);


	int AStarSearch(NodeState  root,
			   unsigned char (*hcalc) (NodeState ), 
			   bool (*IsItGoal) (NodeState ),
			   NodeState * (*children) (NodeState, int &),
			   I64 (*hashCalc)(NodeState ), bool use_cut_off,I64 &generatedNumber, 
			   I64 &expendedNumber, bool UpdateFromListsCut);

};

#endif // !defined(AFX_ASTAR_H__AE0177F8_57A3_4848_A8CD_1156DC834E65__INCLUDED_)
